<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/4
 * Time: 9:24
 */

namespace app\admin\controller;

//\think\Loader::import('controller/Controller', \think\Config::get('traits_path'), EXT);

use app\admin\Controller;
use think\Exception;
use think\Loader;
use app\common\model\PeccancyLog as modelPeccancy;
use app\common\model\PeccData;

class PeccancyLog extends Controller
{
    public function index () {

        if ($this->request->method() == "GET"){
            $where = [
                'pl.is_del' => 0
            ];
            $keyword = $this->request->param('keyword');

            $listRows = 20;
            $filed = "pl.*,ca.name, ca.user_head,ca.phone, ca.car_set, ca.car_model, ca.address";
            $model = new PeccData();
            $list = $model->getUserPecInfoList($where, $filed, $listRows, $this->request, $keyword);

            $this->view->assign('list', $list);
            $this->view->assign("count", $list->total());
            $this->view->assign("page", $list->render());
            $this->view->assign('numPerPage', $list->listRows());

            return $this->view->fetch();
        }

    }

    public function detail() {

        if ($this->request->method()) {
            $id = $this->request->param('id');

            $where = [
                'pl.id' => $id,
            ];
            $filed = "pl.*,ca.name, ua.nickname, ca.user_head,ca.phone, ca.car_set, ca.car_model, ca.address";
            $plModel = new PeccData();
            $data = $plModel->getUserPecDataDetail($where, $filed);

            $data['log_data'] = unserialize($data['log_data']);
            $list = $data['log_data'];

            $this->view->assign('vo', $data);
            $this->view->assign('list', $list);
            return $this->view->fetch();
        }
    }
}